home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Libraries / Runtime / Runtime PPC / Sources / obsolete.s < prev    next >
Encoding:
Text File  |  1995-02-23  |  3.4 KB  |  159 lines  |  [TEXT/MPS ]

  1. #    obsolete.s    -    Obsolete Runtime Support routines for Metrowerks C++ for PowerPC
  2. #
  3. #    Copyright © 1993 metrowerks inc.  All Rights Reserved.
  4. #
  5. #
  6. #    THEORY OF OPERATION
  7. #
  8. #    This file defines runtime support routines that were required for previous
  9. #    versions of the Metrowerks PowerPC compiler but are now obsolete. They
  10. #    are provided in case existing libraries require them for linking, but
  11. #    they will eventually be removed from the standard PPC Runtime Library.
  12. #
  13. #    BUILD INSTRUCTIONS
  14. #
  15. #    To assemble this file:
  16. #
  17. #        ppcasm obsolete.s -o obsolete.o
  18. #
  19. #    The object file obsolete.o can be added directly to any CodeWarrior™ project.
  20. #
  21.  
  22.         dialect    powerpc
  23.  
  24. #
  25. #    Private Data
  26. #
  27.         csect    __constants{RO}
  28.         dc.l    0x43300000            # integer->floating conversion constant
  29.         dc.l    0x80000000
  30.         dc.l    0x43300000            # unsigned->floating conversion constant
  31.         dc.l    0x00000000
  32.  
  33. #
  34. #    TOC pointers
  35. #
  36.         toc
  37.         tc        __constants{TC}, __constants{RO}
  38.  
  39.  
  40. #    __cvt_int2single    -    convert 32-bit integer to floating-point single
  41. #
  42. #    Convert the 32-bit integer in R3 to a floating-point single and return
  43. #    the result in F1.
  44. #
  45.         csect    .__cvt_int2single{PR}
  46.         export    .__cvt_int2single{PR}
  47.         lwz        r4,__constants{TC}(RTOC)
  48.         xoris    r0,r3,0x8000
  49.         lfd        fp0,0(r4)            # fp0 = integer->floating conversion constant
  50.         stw        r0,-4(SP)
  51.         lis        r0,0x4330
  52.         stw        r0,-8(SP)
  53.         lfd        fp1,-8(SP)
  54.         fsubs    fp1,fp1,fp0
  55.         blr
  56.  
  57.  
  58. #    __cvt_int2double    -    convert 32-bit integer to floating-point double
  59. #
  60. #    Convert the 32-bit integer in R3 to a floating-point double and return
  61. #    the result in F1.
  62. #
  63.         csect    .__cvt_int2double{PR}        
  64.         export    .__cvt_int2double{PR}
  65.         lwz        r4,__constants{TC}(RTOC)
  66.         xoris    r0,r3,0x8000
  67.         lfd        fp0,0(r4)            # fp0 = integer->floating conversion constant
  68.         stw        r0,-4(SP)
  69.         lis        r0,0x4330
  70.         stw        r0,-8(SP)
  71.         lfd        fp1,-8(SP)
  72.         fsub    fp1,fp1,fp0
  73.         blr
  74.  
  75.  
  76. #    __cvt_uns2single    -    convert 32-bit unsigned to floating-point single
  77. #
  78. #    Convert the 32-bit integer in R3 to a floating-point single and return
  79. #    the result in F1.
  80. #
  81.         csect    .__cvt_uns2single{PR}
  82.         export    .__cvt_uns2single{PR}
  83.         lwz        r4,__constants{TC}(RTOC)
  84.         stw        r3,-4(SP)
  85.         lfd        fp0,8(r4)            # fp0 = unsigned->floating conversion constant
  86.         lis        r0,0x4330
  87.         stw        r0,-8(SP)
  88.         lfd        fp1,-8(SP)
  89.         fsubs    fp1,fp1,fp0
  90.         blr
  91.  
  92.  
  93. #    __cvt_uns2double    -    convert 32-bit unsigned to floating-point double
  94. #
  95. #    Convert the 32-bit integer in R3 to a floating-point single and return
  96. #    the result in F1.
  97. #
  98.         csect    .__cvt_uns2double{PR} 
  99.         export    .__cvt_uns2double{PR}
  100.         lwz        r4,__constants{TC}(RTOC)
  101.         stw        r3,-4(SP)
  102.         lfd        fp0,8(r4)            # fp0 = unsigned->floating conversion constant
  103.         lis        r0,0x4330
  104.         stw        r0,-8(SP)
  105.         lfd        fp1,-8(SP)
  106.         fsub    fp1,fp1,fp0
  107.         blr
  108.  
  109.         
  110. #    __blockmove        -    move (unaligned) block of data
  111. #
  112. #    Move the # bytes in R5 from the address in R4 to the address in R3.
  113. #    The # bytes is at least 128. We move the data in 32-byte chunks.
  114. #
  115.         csect    .__blockmove{PR}
  116.         export    .__blockmove{PR}
  117.  
  118. #    save some nonvolatile registers that we need
  119.  
  120.         stw        r13,-4(SP)
  121.         stw        r14,-8(SP)
  122.         stw        r15,-12(SP)
  123.  
  124. #    set XER = chunk size
  125.  
  126.         li        r7,32
  127.         mtxer    r7
  128.  
  129. #    set CTR = #chunks to move
  130.  
  131.         rlwinm    r8,r5,27,5,31
  132.         mtctr    r8
  133.  
  134. #    set    R5 = remainder
  135.     
  136.         rlwinm.    r5,r5,0,27,31    #    cr0(eq) = no remainder
  137.         
  138. #    copy 32-byte chunks
  139.  
  140.         li        r6,0
  141. loop:    lswx    r8,r6,r4
  142.         stswx    r8,r6,r3
  143.         addi    r6,r6,32
  144.         bdnz    loop
  145.         beq        exit            #    return if no remainder
  146.         
  147. #    copy remainder
  148.  
  149.         mtxer    r5
  150.         lswx    r8,r6,r4
  151.         stswx    r8,r6,r3
  152.  
  153. #    restore registers and return
  154.  
  155. exit:    lwz        r15,-12(SP)
  156.         lwz        r14,-8(SP)
  157.         lwz        r13,-4(SP)
  158.         blr
  159.